In computer programming, a critical section is a piece of code that needs to be executed by one process or thread at a time. Some synchronization mechanism is required at the entry and exit of the critical section to ensure exclusive use. For example, a lock may be acquired at the entry of the critical section and released at the exit. This causes execution of critical sections of code to be serialized, which can be inefficient when there is no contention for the lock during this time. In other synchronization mechanisms, the critical section is executed speculatively, or without acquiring a lock. If another thread attempts to execute the critical section in a conflicting manner, speculation fails. Speculation is retried until the critical section is successfully executed. This can also be inefficient if speculation often fails. In addition, significant hardware support may be required to save and restore architectural state upon speculation and failure of speculation. An improved synchronization mechanism is needed.